package code.remote {

import mx.rpc.events.FaultEvent;
import mx.rpc.events.ResultEvent;
import mx.utils.ObjectUtil;
	

public class InsertTopicRequest extends AbstractActionRequest {
	
	private static const REQUEST_TYPE: String = "insert_topic";
	
	private var title: String;
	private var categoryId: int;
	private var userId: int;
	
	public function InsertTopicRequest(title: String, categoryId: int, userId: int = -1) {
		super(REQUEST_TYPE);
		
		this.title = title;
		this.categoryId = categoryId;
		this.userId = userId;
	}
	
	protected final override function getXmlData(): String {
		if(this.userId == -1) {
			return "<Request><NeededTopic><Title>"+this.title+"</Title><CategoryId>"+this.categoryId+"</CategoryId></NeededTopic></Request>"
		}
		return '<Request><OfferedTopic><Title>'+this.title+'</Title><CategoryId>'+this.categoryId+'</CategoryId><User><UserId>'+this.userId+'</UserId></User></OfferedTopic></Request>';
	}
	
}
}